home *** CD-ROM | disk | FTP | other *** search
/ Best of www.BestZips.com (Collector's Edition) / Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO / tutorial / adatu311.zip / TXT2DAT.ADA < prev    next >
Text File  |  1996-01-10  |  3KB  |  57 lines

  1. -- TXT2DAT.ADA   Ver. 3.11   10-JAN-1996   Copyright 1988-1996 John J. Herro
  2. --
  3. -- SOFTWARE INNOVATIONS TECHNOLOGY          http://members.aol.com/AdaTutor
  4. -- 1083 MANDARIN DR NE                      ftp://members.aol.com/AdaTutor
  5. -- PALM BAY FL 32905-4706
  6. --                                          johnherro@aol.com
  7. -- (407) 951-0233                           john.herro%374-38-2@satlink.oau.org
  8. --
  9. -- After running DAT2TXT on a PC and transferring the resulting TUTOR.TXT
  10. -- file to another computer, compile and run this program on the other
  11. -- computer to create ADA_TUTR.DAT on that machine.
  12. --
  13.  
  14. with Direct_IO, Text_IO;
  15. procedure TXT2DAT is
  16.    subtype Block_Subtype is String(1 .. 64);
  17.    package Random_IO is new Direct_IO(Block_Subtype);
  18.    Text_File  : Text_IO.File_Type;                           -- The input file.
  19.    Data_File  : Random_IO.File_Type;                        -- The output file.
  20.    OK         : Boolean := True;     -- True when both files open successfully.
  21.    Input      : String(1 .. 65);           -- Line of text read from TUTOR.TXT.
  22.    Len        : Integer;                 -- Length of line read from TUTOR.TXT.
  23.    Legal_Note : constant String := " Copyright 1988-96 John J. Herro ";
  24.                        -- Legal_Note isn't used by the program, but it causes
  25.                        -- most compilers to place this string in the .EXE file.
  26. begin
  27.    begin
  28.       Text_IO.Open(Text_File, Mode => Text_IO.In_File, Name => "TUTOR.TXT");
  29.    exception
  30.       when Text_IO.Name_Error =>
  31.          Text_IO.Put_Line(
  32.               "I'm sorry.  The file TUTOR.TXT seems to be missing.");
  33.          OK := False;
  34.    end;
  35.    begin
  36.       Random_IO.Create(Data_File, Random_IO.Out_File, Name => "ADA_TUTR.DAT");
  37.    exception
  38.       when others =>
  39.          Text_IO.Put_Line("I'm sorry.  I can't seem to create ADA_TUTR.DAT.");
  40.          Text_IO.Put_Line("Perhaps that file already exists?");
  41.          OK := False;
  42.    end;
  43.    if OK then
  44.       while not Text_IO.End_Of_File(Text_File) loop
  45.          Text_IO.Get_Line(File => Text_File, Item => Input, Last => Len);
  46.          if Len > 3 then  -- In case extra CRs/LFs were added to the text file.
  47.             Input(Len + 1 .. 64) := (others => ' ');
  48.               -- In case trailing blanks were lost when transferring TUTOR.TXT.
  49.             Random_IO.Write(Data_File, Item => Input(1 .. 64));
  50.          end if;
  51.       end loop;
  52.       Text_IO.Close(Text_File);
  53.       Random_IO.Close(Data_File);
  54.       Text_IO.Put_Line("ADA_TUTR.DAT created.");
  55.    end if;
  56. end TXT2DAT;
  57.